// Copyright 2018 The MACE Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This is a generated file. DO NOT EDIT!

#include <string>

#include "mace/utils/macros.h"
#include "mace/proto/mace.pb.h"
#include "mace/public/mace.h"
#include "mace/port/env.h"
#include "mace/utils/logging.h"

namespace mace {
namespace {{model_tag}} {

{% for i in range(multi_net.net_def|length) %}
extern void CreateNet{{i}}(mace::NetDef *net);
{% endfor %}

}  // namespace {{ model_tag }}

namespace {

void CreateNets(MultiNetDef *multi_net_def) {
  MACE_LATENCY_LOGGER(1, "Create tensors");

  multi_net_def->mutable_net_def()->Reserve({{ multi_net.net_def|length }});
  {% for i in range(multi_net.net_def|length) %}
  mace::{{model_tag}}::CreateNet{{i}}(multi_net_def->add_net_def());
  {% endfor %}
}
}  // namespace

namespace {{model_tag}} {

MACE_API const std::shared_ptr<MultiNetDef> CreateMultiNet() {
  MACE_LATENCY_LOGGER(1, "Create multi net ", {{ multi_net.name|default("undefined")|tojson }});

  std::shared_ptr<MultiNetDef> multi_net_def(new MultiNetDef());
  multi_net_def->set_version_code({{ multi_net.version_code }});
  multi_net_def->set_name({{ multi_net.name|tojson }});
  CreateNets(multi_net_def.get());

  {% for idx in range(multi_net.input_tensor|length) %}
  multi_net_def->add_input_tensor({{ multi_net.input_tensor[idx]|tojson }});
  {% endfor %}

  {% for idx in range(multi_net.output_tensor|length) %}
  multi_net_def->add_output_tensor({{ multi_net.output_tensor[idx]|tojson }});
  {% endfor %}

  return multi_net_def;
}

MACE_API const std::string ModelName() {
  return {{ model_tag|tojson }};
}

MACE_API const std::string ModelChecksum() {
  return {{ checksum|tojson }};
}

MACE_API const std::string ModelBuildTime() {
  return {{ build_time|tojson }};
}

}  // namespace {{model_tag}}
}  // namespace mace
